-
Notifications
You must be signed in to change notification settings - Fork 800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix blocks missing translations in simple sites #33190
Conversation
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
Mu Wpcom plugin:
|
Are you an Automattician? The PR will need to be tested on WordPress.com. This comment will be updated with testing instructions as soon the build is complete. |
@@ -7,8 +7,6 @@ import './editor.scss'; | |||
import './components/feedback/style.scss'; | |||
|
|||
registerJetpackBlockFromMetadata( metadata, { | |||
// The API version needs to be explicitly specified in this instance for styles to be loaded. | |||
apiVersion: metadata.apiVersion, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metadata are added to settings in registerJetpackBlockFromMetadata
anyway.
@@ -1,10 +1,10 @@ | |||
{ | |||
"$schema": "https://schemas.wp.org/trunk/block.json", | |||
"apiVersion": 3, | |||
"apiVersion": 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the changes brought to registerJetpackBlockFromMetadata
, the implementation of the edit
function (I believe) requires the block to use the first version of the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I think this can be merged after issues with the builds are resolved.
for ( const prop in props ) { | ||
if ( LOCALIZED_BLOCK_PROPERTIES.includes( prop ) ) { | ||
// eslint-disable-next-line | ||
result[ prop ] = _x( props[ prop ], null, metadata.textdomain || DEFAULT_TEXTDOMAIN ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(most of this is already known to the people involved via Slack discussions, but to close the loop I'll repeat it here)
I think this only accidentally works if your translation files still have the translations from
jetpack/projects/plugins/jetpack/extensions/blocks/business-hours/index.js
Lines 76 to 77 in 427e370
title: __( 'Business Hours', 'jetpack' ), | |
description: __( 'Display opening hours for your business.', 'jetpack' ), |
WordPress intends for the translation to happen on the PHP side during block registration (here), then the already-translated texts are sent to JS via a generated call to wp.blocks.unstable__bootstrapServerSideBlockDefinitions
(here, here, here, or here).
That PHP code path is only reached when using register_block_type_from_metadata()
, or passing a path to the block.json to register_block_type()
. We instead pass a WP_Block_Type object. So we'd either need to change our code to pass the block.json path, or duplicate the relevant logic (plus any other needed logic for any other core block.json registeration features) when creating our WP_Block_Type
.
Close in favour of #33326. |
Fixes p1694788078746839-slack-CDLH4C1UZ
Proposed changes:
#32698, #32815, and #33073 introduced localization issues for simple sites: block titles and descriptions were displayed in English no matter the user's selected language. This PR fixes it.
The blocks involved are: Business Hours, AI Chat, Amazon, Blogroll, Google Docs Embed, Recipe, Create with Voice.
Other information:
Jetpack product discussion
n/a
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
jetpack build plugins/jetpack
.Blocks info translated to French